// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_ok.java

package purchase.file;

import include.nseer_cookie.*;
import include.nseer_db.nseer_db_backup1;
import include.operateDB.CdefineUpdate;
import java.io.IOException;
import java.net.URL;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import javax.servlet.jsp.JspFactory;
import validata.ValidataTag;

public class check_ok extends HttpServlet
{

	public check_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		HttpSession dbSession = request.getSession();
		JspFactory _jspxFactory = JspFactory.getDefaultFactory();
		javax.servlet.jsp.PageContext pageContext = _jspxFactory.getPageContext(this, request, response, "", true, 8192, true);
		javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
		try
		{
			HttpSession session = request.getSession();
			nseer_db_backup1 design_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 purchase_db = new nseer_db_backup1(dbApplication);
			if (purchase_db.conn((String)dbSession.getAttribute("unit_db_name")) && design_db.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				counter count = new counter(dbApplication);
				ValidataTag vt = new ValidataTag();
				String provider_ID = request.getParameter("provider_ID");
				String config_id = request.getParameter("config_id");
				String kind_chain = request.getParameter("fileKind_chain");
				String chain_id = Divide1.getId(kind_chain);
				String chain_name = Divide1.getName(kind_chain);
				String purchaser = request.getParameter("purchaser");
				String purchaser_ID = request.getParameter("purchaser_ID");
				String provider_name = request.getParameter("provider_name");
				String provider_address = request.getParameter("provider_address");
				String type = request.getParameter("type");
				String provider_class = request.getParameter("class");
				String used_provider_name = request.getParameter("used_provider_name");
				String provider_bank = request.getParameter("provider_bank");
				String provider_account = request.getParameter("provider_account");
				String provider_web = request.getParameter("provider_web");
				String provider_tel1 = request.getParameter("provider_tel1");
				String provider_fax = request.getParameter("provider_fax");
				String provider_postcode = request.getParameter("provider_postcode");
				String contact_person1 = request.getParameter("contact_person1");
				String contact_person1_department = request.getParameter("contact_person1_department");
				String contact_person1_duty = request.getParameter("contact_person1_duty");
				String contact_person1_sex = request.getParameter("contact_person1_sex");
				String contact_person1_office_tel = request.getParameter("contact_person1_office_tel");
				String contact_person1_home_tel = request.getParameter("contact_person1_home_tel");
				String contact_person1_mobile = request.getParameter("contact_person1_mobile");
				String contact_person1_email = request.getParameter("contact_person1_email");
				String contact_person2 = request.getParameter("contact_person2");
				String contact_person2_department = request.getParameter("contact_person2_department");
				String contact_person2_duty = request.getParameter("contact_person2_duty");
				String contact_person2_sex = request.getParameter("contact_person2_sex");
				String contact_person2_office_tel = request.getParameter("contact_person2_office_tel");
				String contact_person2_home_tel = request.getParameter("contact_person2_home_tel");
				String contact_person2_mobile = request.getParameter("contact_person2_mobile");
				String contact_person2_email = request.getParameter("contact_person2_email");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String checker_ID = request.getParameter("checker_ID");
				String bodyc = new String(request.getParameter("invoice_info").getBytes("UTF-8"), "UTF-8");
				String invoice_info = exchange.toHtml(bodyc);
				String bodya = new String(request.getParameter("demand_products").getBytes("UTF-8"), "UTF-8");
				String demand_products = exchange.toHtml(bodya);
				String bodyb = new String(request.getParameter("recommend_products").getBytes("UTF-8"), "UTF-8");
				String recommend_products = exchange.toHtml(bodyb);
				if (!vt.validata((String)dbSession.getAttribute("unit_db_name"), "purchase_file", "provider_ID", provider_ID, "check_tag").equals("1"))
				{
					if (provider_ID == null || provider_ID.equals(""))
						provider_ID = NseerId.getId(getClass().getResource("").toString(), (String)dbSession.getAttribute("unit_db_name"));
					try
					{
						String sql = (new StringBuilder("update purchase_file set chain_id='")).append(chain_id).append("',chain_name='").append(chain_name).append("',provider_ID='").append(provider_ID).append("',provider_name='").append(provider_name).append("',provider_address='").append(provider_address).append("',provider_class='").append(provider_class).append("',type='").append(type).append("',provider_bank='").append(provider_bank).append("',provider_account='").append(provider_account).append("',provider_web='").append(provider_web).append("',provider_tel1='").append(provider_tel1).append("',provider_fax='").append(provider_fax).append("',provider_postcode='").append(provider_postcode).append("',used_provider_name='").append(used_provider_name).append("',contact_person1='").append(contact_person1).append("',contact_person1_department='").append(contact_person1_department).append("',contact_person1_duty='").append(contact_person1_duty).append("',contact_person1_sex='").append(contact_person1_sex).append("',contact_person1_office_tel='").append(contact_person1_office_tel).append("',contact_person1_home_tel='").append(contact_person1_home_tel).append("',contact_person1_mobile='").append(contact_person1_mobile).append("',contact_person1_email='").append(contact_person1_email).append("',contact_person2='").append(contact_person2).append("',contact_person2_department='").append(contact_person2_department).append("',contact_person2_duty='").append(contact_person2_duty).append("',contact_person2_sex='").append(contact_person2_sex).append("',contact_person2_office_tel='").append(contact_person2_office_tel).append("',contact_person2_home_tel='").append(contact_person2_home_tel).append("',contact_person2_mobile='").append(contact_person2_mobile).append("',contact_person2_email='").append(contact_person2_email).append("',invoice_info='").append(invoice_info).append("',demand_products='").append(demand_products).append("',recommend_products='").append(recommend_products).append("',checker='").append(checker).append("',check_time='").append(check_time).append("',purchaser='").append(purchaser).append("',purchaser_ID='").append(purchaser_ID).append("' where provider_ID='").append(provider_ID).append("'").toString();
						purchase_db.executeUpdate(sql);
						CdefineUpdate CdefineUpdate = new CdefineUpdate();
						sql = CdefineUpdate.update("purchase_file", "provider_ID", provider_ID, request);
						purchase_db.executeUpdate(sql);
						sql = (new StringBuilder("update purchase_workflow set checker='")).append(checker).append("',checker_ID='").append(checker_ID).append("',check_time='").append(check_time).append("',check_tag='1' where object_ID='").append(provider_ID).append("' and config_id='").append(config_id).append("'").toString();
						purchase_db.executeUpdate(sql);
						sql = (new StringBuilder("select id from purchase_workflow where object_ID='")).append(provider_ID).append("' and check_tag='0'").toString();
						ResultSet rset = purchase_db.executeQuery(sql);
						if (!rset.next())
						{
							sql = (new StringBuilder("update purchase_file set check_tag='1' where provider_ID='")).append(provider_ID).append("'").toString();
							purchase_db.executeUpdate(sql);
						}
					}
					catch (Exception ex)
					{
						ex.printStackTrace();
					}
					response.sendRedirect((new StringBuilder("purchase/file/check_choose_attachment.jsp?provider_ID=")).append(provider_ID).toString());
				} else
				{
					response.sendRedirect("purchase/file/check_ok_a.jsp");
				}
				purchase_db.commit();
				design_db.commit();
				purchase_db.close();
				design_db.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
